<template>
	<view class="main">
		<nav-bar :isBack="false" :isFixed="false" transparent titleColor="#fff" title="个人中心"></nav-bar>
		<!-- 个人信息 -->
		<view class="info" >
			<view class="info-picdir" @click="uploadAvatar">
				<image :src="baseImage + usual.seekerAvatar1" mode=""></image>
			</view>
			<view class="info-data">
				<view class="info-data-line">
					<view class="info-data-name"  @click="toUrl('/pagesroot/login/login')">
						点击登录/注册
					</view>
					<view class="info-data-brief">
						可查看更多信息
					</view>
				</view>
				<!-- <view class="info-state" :class="info.status==0? 'auth':''">
					{{info.status==0? '已认证':'未认证'}}
				</view> -->
			</view>
			<view class="info-line">
				<view class="info-item"   @click="toUrl('/pagesroot/login/login')">
					<view class="info-item-icon">
						<image :src="imgUrl + 'homeMainIcon4.png'" mode=""></image>
					</view>
					<view class="info-item-label">
						求职沟通
					</view>
					<!-- <view class="info-item-num">
						{{ qiuzhiCount || 0}}
					</view> -->
				</view>
				<view class="info-item"  @click="toUrl('/pagesroot/login/login')">
					<view class="info-item-icon">
						<image :src="imgUrl + 'homeMainIcon3.png'" mode=""></image>
					</view>
					<view class="info-item-label">
						收藏
					</view>
					<!-- <view class="info-item-num">
						{{ favCount || 0}}
					</view> -->
				</view>
			</view>
			
			<view class="info-bj">
				<image :src="imgUrl + 'homeQiuzhiduanMainBj.png'" mode=""></image>
			</view>
			
		</view>
		<!-- 菜单区域 -->
		<view class="cata-menu cata-common">
			<view class="cata-menu-item" @click="toUrl('/pagesroot/login/login')">
				<view class="cata-menu-item-icon">
					<image :src="imgUrl + 'homeMenuIcon8.png'" mode=""></image>
				</view>
				<view class="cata-menu-item-title">
					求职意向
				</view>
				<view class="cata-menu-item-more">
					<van-icon name="arrow" color="#ccc" />
				</view>
			</view>
			<view class="cata-menu-item" @click="toUrl('/pagesroot/login/login')">
				<view class="cata-menu-item-icon">
					<image :src="imgUrl + 'homeMenuIcon9.png'" mode=""></image>
				</view>
				<view class="cata-menu-item-title">
					个人信息
				</view>
				<view class="cata-menu-item-more">
					<van-icon name="arrow" color="#ccc" />
				</view>
			</view>
			<view class="cata-menu-item" @click="toUrl('/pagesroot/login/login')">
				<view class="cata-menu-item-icon">
					<image :src="imgUrl + 'homeMenuIcon3.png'" mode=""></image>
				</view>
				<view class="cata-menu-item-title">
					结业点评
				</view>
				<view class="cata-menu-item-more">
					<van-icon name="arrow" color="#ccc" />
				</view>
			</view>
		<!-- 	<view class="cata-menu-item" @click="toUrl('/pages-companies/qiuzhiduan/post/apply')">
				<view class="cata-menu-item-icon">
					<image :src="imgUrl + 'homeMenuIcon10.png'" mode=""></image>
				</view>
				<view class="cata-menu-item-title">
					实习证明
				</view>
				<view class="cata-menu-item-more">
					<van-icon name="arrow" color="#ccc" />
				</view>
			</view> -->
			<view class="cata-menu-item" @click="toUrl('/pagesroot/login/login')">
				<view class="cata-menu-item-icon">
					<image :src="imgUrl + 'homeMenuIcon11.png'" mode=""></image>
				</view>
				<view class="cata-menu-item-title">
					隐私设置
				</view>
				<view class="cata-menu-item-more">
					<van-icon name="arrow" color="#ccc" />
				</view>
			</view>
		</view>
		<view class="cata-menu cata-common">
			<view class="cata-menu-item" @click="toUrl('/pages/ucenter/common/about')">
				<view class="cata-menu-item-icon">
					<image :src="imgUrl + 'homeMenuIcon5.png'" mode=""></image>
				</view>
				<view class="cata-menu-item-title">
					关于我们
				</view>
				<view class="cata-menu-item-more">
					<van-icon name="arrow" color="#ccc" />
				</view>
			</view>
			<!-- <view class="cata-menu-item">
				<view class="cata-menu-item-icon">
					<image :src="imgUrl + 'homeMenuIcon12.png'" mode=""></image>
				</view>
				<view class="cata-menu-item-title">
					我的客服
				</view>
				<view class="cata-menu-item-more">
					<van-icon name="arrow" color="#ccc" />
				</view>
			</view> -->
			<view class="cata-menu-item"  @click="toUrl('/pages/ucenter/detail?cataName=隐私政策')">
				<view class="cata-menu-item-icon">
					<image :src="imgUrl + 'homeMenuIcon6.png'" mode=""></image>
				</view>
				<view class="cata-menu-item-title">
					隐私政策
				</view>
				<view class="cata-menu-item-more">
					<van-icon name="arrow" color="#ccc" />
				</view>
			</view>
			<!-- <view class="cata-menu-item" @click="loginOut()">
				<view class="cata-menu-item-icon">
					<image :src="imgUrl + 'homeMenuIcon7.png'" mode=""></image>
				</view>
				<view class="cata-menu-item-title">
					安全退出
				</view>
				<view class="cata-menu-item-more">
					<van-icon name="arrow" color="#ccc" />
				</view>
			</view> -->
		</view>
		<view style="margin-top: 60upx;">
			 <view class="some" v-html="usual.bottomCnt">
			 </view>
			 <view class="some">
			 	<span @click="toUrl('/pages/ucenter/common/img?str=hrZheng')">人力资源许可证</span>
				<span> {{ ' '+'|'+' '}} </span>
				<span @click="toUrl('/pages/ucenter/common/img?str=businessLicense')"> 营业执照</span>
			 </view>
			
		</view>
		<!-- 背景图 -->
		<view class="main-bj">
			<image :src="imgUrl + 'homeQiuzhiduanBj.png'" mode="widthFix"></image>
		</view>
	</view>
</template>

<script>
	import {
		mapGetters,
		mapState
	} from 'vuex'
	import { NavBar } from '@/components/Navbar.vue'
	import {getMyInfo ,getMyTongji,updateSeekerAvatar} from "@/core/web-api/qiuzhiduan.js"
	import {uploadFile,formatImage} from "@/utils/util.js"
	export default {
		components:{
			NavBar
		},
		data() {
			return {
				info: {
				},
				favCount:0,
				qiuzhiCount:0,
			}
		},
		methods: {
			
			/**
			 * 更换头像
			 */
			uploadAvatar() {
				let that = this;
				uni.chooseImage({
					success:(e)=> {
						let obj = formatImage(e);
						uploadFile(obj[0]).then(res => {
							updateSeekerAvatar({
								avatar:res,
							}).then(data => {
								if (data.code == 20000) {
									that.info.avatar = res;
									that.$store.commit("setUserInfo",that.info)
									uni.showToast({
										title:"上传成功"
									})
								}
							})
						})
					},
					fail() {
						uni.showToast({
							title:"上传失败",
							icon:"none"
						})
					}
				})
			
			},
			toUrl(url){
				uni.navigateTo({
					url
				})
			},
			getUserInfo(){
				getMyInfo().then(res=>{
					if(res.code==20000){
						this.info = res.data.detail;
						this.$store.commit("setUserInfo",res.data.detail)
					}
				})
			},
			getMyTongji(){
				getMyTongji().then(res=>{
					if(res.code==20000){
						this.favCount = res.data.favCount
						this.qiuzhiCount = res.data.qiuzhiCount
					}
				})
			},
			loginOut(){
				uni.showModal({
					title:"温馨提示",
					content:"是否退出登录？",
					success: (val) => {
						if(val.confirm){
							this.$store.commit("setUserInfo", {})
							this.$store.commit("setType", "")
							this.$store.commit("setToken","")
							this.$socket.onUnload();
							uni.reLaunch({
								url:"/pagesroot/login/login"
							})
						}
					}
				})
				
			},
			childOnShow() {
				
			}
		},
		created() {
			this.getUserInfo();
			this.getMyTongji();
		},
		computed: {
			...mapGetters(['getStateAndMenuRectHeight','getNavbar', 'getStateHeight', 'getSafeBottom']),
			...mapState(['userInfo','type','baseImage','imgUrl','usual'])
		}
	}
</script>

<style scoped lang="less">
	.info-data-brief{
		overflow: hidden;  /* 隐藏超出的内容 */
		word-break: break-all; /* break-all(允许在单词内换行。) */
		text-overflow: ellipsis; /* 超出部分省略号 */
		display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
		-webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
		-webkit-line-clamp: 2; /** 显示的行数 **/
	}
	.main {
		width: 100%;
		padding: 0 30upx;
		box-sizing: border-box;
		padding-bottom: 30upx;
		&-bj {
			position: fixed;
			width: 100vw;
			left: 0;
			top: 0;
			z-index: -1;

			image {
				width: 100%;
			}
		}
	}
	
	.some{
		color:#aaaaaa;
		text-align:center;
		font-size: 26upx;
		line-height: 1.8;
	}

	.info {
		width: 100%;
		width: 690upx;
		position: relative;
		border-radius: 12upx;
		margin-bottom: 40upx;
		box-shadow: 2upx 0 26upx rgba(0,102,224,.3);
		padding:30upx;
		box-sizing: border-box;
		z-index: 2;
		margin-top: 50upx;
		&-picdir {
			width: 128upx;
			height: 128upx;
			border-radius: 50%;
			display: flex;
			justify-content: center;
			align-items: center;
			border: 2upx solid #fff;
			box-sizing: border-box;
			position: absolute;
			left: 30upx;
			top: -30upx;

			image {
				width: 128upx;
				height: 128upx;
				background-color: #fff;
				border-radius: 50%;
			}
		}
		
		&-data{
			width: 100%;
			padding-left: 150upx;
			display: flex;
			align-items: center;
			box-sizing: border-box;
			&-line{
				flex:1;
			}
			&-name{
				font-size: 36upx;
				color: #292b32;
			}
			&-brief{
				font-size: 22upx;
				color: #686d74;
				margin-top: 10upx;
			}
		}

		&-line{
			display: flex;
			align-items: center;
			padding:0 50upx;
			box-sizing: border-box;
			width: 100%;
			margin-top:50upx;
			justify-content: space-between;
		}
		&-item{
			display: flex;
			align-items: center;
			&-icon{
				width: 40upx;
				height: 40upx;
				image{
					width: 40upx;
					height: 40upx;
				}
				margin-right: 15upx;
			}
			&-label{
				font-size: 28upx;
				color: #292b32;
				margin-right: 30upx;
			}
			&-num{
				font-size: 28upx;
				color: #292b32;
			}
		}
		
		&-bj{
			position: absolute;
			width: 100%;
			height: 100%;
			left: 0;
			top: 0;
			z-index: -1;
			image{
				width: 100%;
				height: 100%;
			}
		}

		&-state {
			width: 148upx;
			height: 56upx;
			border-radius: 50upx;
			text-align: center;
			line-height: 56upx;
			background-color: #ccc;
			color: #333;
			font-size: 22upx;

			&.auth {
				// background-color: unset;
				background: linear-gradient(to bottom, #4b6bfe, #6bacff);
				color: #eef0f5;
			}
		}
	}

	.cata {
		&-common {
			width: 100%;
			background-color: #fff;
			border-radius: 33upx;
			box-shadow: 0upx 0upx 24upx rgba(70, 178, 255, .41);
			box-sizing: border-box;
		}

		&-main {
			margin-bottom: 35upx;
			width: 100%;
			padding: 40upx 70upx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			&-item {
				display: flex;
				flex-direction: column;
				align-items: center;
				position: relative;

				&-icon image {
					width: 60upx;
					height: 60upx;
				}

				&-title {
					font-size: 26upx;
					color: #000000;
				}

			}
		}

		&-menu {
			margin-bottom: 35upx;
			width: 100%;

			&-item {
				display: flex;
				align-items: center;
				padding: 30upx 25upx;
				border-bottom: 2upx solid #f8f8f8;

				&:last-child {
					border-bottom: 0;
				}

				&-icon {
					width: 40upx;
					height: 40upx;

					image {
						width: 40upx;
						height: 40upx;
					}
				}

				&-title {
					font-size: 28upx;
					color: #4d4d4d;
					padding: 0 20upx;
					box-sizing: border-box;
					flex: 1;
				}
			}
		}
	}
</style>